{
 "metadata": {
  "name": "",
  "signature": "sha256:0709037542aa83d18643c0342b485288c35cb9734fa04f9a326f47cf811d1c27"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "import pandas as pd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "data = pd.read_csv('spam_train.csv', header = None)\n",
      "data = data.fillna(0)\n",
      "data_array = np.array(data)\n",
      "x = data_array[:,1:-1]\n",
      "x[:, -1] /= np.mean(x[:, -1])\n",
      "x[:, -2] /= np.mean(x[:, -2])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 14
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "y = data_array[:, -1]\n",
      "x_train, x_val = x[0:3500, :], x[3500:, :]\n",
      "y_train, y_val = y[0:3500], y[3500:]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 16
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "np.save(\"train_data.npy\", x_train)\n",
      "np.save(\"train_label.npy\", y_train)\n",
      "np.save(\"val_data.npy\", x_val)\n",
      "np.save(\"val_label.npy\", y_val)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 18
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}